//
//  Home.m
//  fenlegu
//
//  Created by lazy on 3/28/13.
//  Copyright (c) 2013 lazy. All rights reserved.
//

#import "Home.h"
#import "Weiba.h"


@interface UINavigationBar(CustomImage)
- (void)drawRect:(CGRect)rect;
@end
//自定义UINavigationBar背景图片
@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect {
    UIImage *image = [UIImage imageNamed:@"nav_bg.png"];
    [image drawInRect:CGRectMake(0,0, self.frame.size.width,self.frame.size.height)];
}
@end


@interface Home ()

@end

@implementation Home

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        self.title = @"首页";
        
        UIImage *title_bg = [UIImage imageNamed:@"nav_bg.png"];  //获取图片
        //CGSize titleSize = self.navigationController.navigationBar.bounds.size;  //获取Navigation Bar的位置和大小
        //title_bg = [self.nav scaleToSize:title_bg size:titleSize];//设置图片的大小与Navigation Bar相同
        [self.navigationController.navigationBar
         setBackgroundImage:title_bg
         forBarMetrics:UIBarMetricsDefault];
        
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    
    //定义右侧按钮
//    UIButton *rightButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 60, 40)];
//    [rightButton setImage:[UIImage imageNamed:@"search_button.png"] forState:UIControlStateNormal];
//    [rightButton setImage:[UIImage imageNamed:@"search_button.png"] forState:UIControlStateHighlighted];
//    [rightButton addTarget:self action:@selector(rightAction:) forControlEvents:UIControlEventTouchUpInside];
//    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
//    [rightButton release];
//    
//    self.navigationItem.rightBarButtonItem = rightItem;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dealloc {
    [super dealloc];
    
    
}
- (void)viewDidUnload {
    [super viewDidUnload];
}


@end
